import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入字体图标
import './assets/fonts/iconfont.css'
// 导入全局样式表
import './assets/css/global.css'

import axios from 'axios'
import { Loading } from 'element-ui'
// 声明请求拦截器
let loadingInstance = null
axios.defaults.baseURL = 'http://127.0.0.1:8001/api/'
axios.interceptors.request.use(config => {
  // 展示Loading效果
  loadingInstance = Loading.service({ fullscreen: true })
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须return config
  return config
})
// 声明响应拦截器
axios.interceptors.response.use(response => {
  // 隐藏Loading效果
  loadingInstance.close()
  return response
})

Vue.prototype.$http = axios
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
